package com.hzw.saas.service.project.util;

import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.hzw.saas.service.project.model.ProjectApply;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

/**
 * @author sonam
 * @sine 2021/8/19 6:26 下午
 */
public class PdfUtils {
    /**
     * 创建PDF
     *
     * @param outputStream 输出
     * @param logoInput    logo
     * @param markInput    水印
     * @param projectApply 对象
     */
    public static void createProjectApplyPDF(OutputStream outputStream, InputStream logoInput, InputStream markInput, String markText, ProjectApply projectApply) {
        Document document = new Document();
        PdfReader reader = null;
        PdfStamper stamp = null;
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            PdfWriter.getInstance(document, byteArrayOutputStream);
            document.open();

            PdfPTable table = new PdfPTable(1);
            table.setKeepTogether(true);
            table.setSplitLate(false);
            // 标题
            PdfPCell titleCell = getTitleCell();
            // 申请编号
            PdfPCell noCell = getNoCell(projectApply.getPid());
            // 表格内容
            PdfPTable table1 = getTableContentCell(projectApply);
            // 编号内容
            table.addCell(noCell);
            // 标题内容
            table.addCell(titleCell);
            document.add(table);
            document.add(table1);
            document.close();
            // 创建logo水印
            Image image = Image.getInstance(IoUtil.readBytes(logoInput));
            image.scalePercent(35);
            image.setAbsolutePosition(420, 770);
            // 创建水印
            Image remark = null;
            if (markInput != null) {
                byte[] imageBytes = IoUtil.readBytes(markInput);
                remark = getRemarkImage(imageBytes);
            }

            Rectangle rectangle = document.getPageSize();

            // 为每一页添加水印
            reader = new PdfReader(byteArrayOutputStream.toByteArray());
            stamp = new PdfStamper(reader, outputStream);
            int n = reader.getNumberOfPages();
            for (int i = 1; i <= n; i++) {
                PdfContentByte pdfContentByte = stamp.getOverContent(i);
                if (i == 1) {
                    PdfGState gs1 = new PdfGState();
                    gs1.setFillOpacity(0.9f);
                    pdfContentByte.setGState(gs1);
                    pdfContentByte.addImage(image);
                }

                PdfGState gs2 = new PdfGState();
                gs2.setFillOpacity(0.15f);
                pdfContentByte.setGState(gs2);

                if (remark != null) {
                    int imageHeight = 0;
                    int index = 0;
                    for (int y = (int) rectangle.getHeight(); y >= 0; ) {
                        for (int x = 0; x < rectangle.getWidth(); ) {
                            remark.setAbsolutePosition(x, y);
                            x = x + 20 + (int) (remark.getWidth() * 0.4);
                            imageHeight = (int) (remark.getHeight() * 0.4);
                            index++;
                            if (i == 1 && index == 7) {
                                continue;
                            }
                            pdfContentByte.addImage(remark);
                        }
                        y = y - 100 - imageHeight;
                    }
                } else if (StrUtil.isNotBlank(markText)) {
                    for (int y = (int) rectangle.getHeight() - 50; y >= 0; ) {
                        for (int x = 0; x < rectangle.getWidth() + 150; ) {
                            // 文字水印
                            BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
                            // 开始
                            pdfContentByte.beginText();
                            // 设置水印字体参数及大小   (字体参数，字体编码格式，是否将字体信息嵌入到pdf中（一般不需要嵌入），字体大小)
                            pdfContentByte.setFontAndSize(font, 20);
                            // 设置水印对齐方式 水印内容 X坐标 Y坐标 旋转角度
                            pdfContentByte.showTextAligned(Element.ALIGN_RIGHT, markText, x, y, 35);
                            // 设置水印颜色(灰色)
                            pdfContentByte.setColorFill(BaseColor.GRAY);
                            //结束
                            pdfContentByte.endText();
                            x = x + 150;
                        }
                        y = y - 200;
                    }
                }

            }
        } catch (DocumentException | IOException e) {
            e.printStackTrace();
        } finally {
            try {
                stamp.close();
                reader.close();
            } catch (DocumentException | IOException | NullPointerException e) {
                e.printStackTrace();
            }
        }
    }

    private static Image getRemarkImage(byte[] bytes) throws BadElementException, IOException {
        Image remark = Image.getInstance(bytes);
        remark.setRotationDegrees(37f);
        remark.scalePercent(40);
        return remark;
    }

    private static PdfPTable getTableContentCell(ProjectApply projectApply) {
        PdfPTable table = new PdfPTable(new float[]{30f, 100f, 200f, 150f, 200f});
        table.setTotalWidth(100f);
        Paragraph applyLabel = str2ParaByTwoFont("申请人信息", 9f, BaseColor.BLACK);
        applyLabel.setAlignment(Element.ALIGN_CENTER);
        PdfPCell cell = initPdfCell(applyLabel);
        cell.setColspan(1);
        cell.setRowspan(5);
        table.addCell(cell);

        Paragraph nameLabel = str2ParaByTwoFont("姓名", 9f, BaseColor.BLACK);
        nameLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell nameCell = initPdfCell(nameLabel);
        setLRPadding(nameCell);
        table.addCell(nameCell);

        Paragraph nameContent = str2ParaByTwoFont(projectApply.getRealName(), 9f, BaseColor.BLACK);
        nameContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell nameContentCell = initPdfCell(nameContent);
        setLRPadding(nameContentCell);
        table.addCell(nameContentCell);

        Paragraph usernameLabel = str2ParaByTwoFont("鸿之微云用户名", 9f, BaseColor.BLACK);
        usernameLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell usernameCell = initPdfCell(usernameLabel);
        setLRPadding(nameContentCell);
        table.addCell(usernameCell);

        Paragraph usernameContent = str2ParaByTwoFont(projectApply.getUserName(), 9f, BaseColor.BLACK);
        usernameContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell usernameContentCell = initPdfCell(usernameContent);
        setLRPadding(usernameContentCell);
        table.addCell(usernameContentCell);

        Paragraph phoneLabel = str2ParaByTwoFont("电话", 9f, BaseColor.BLACK);
        phoneLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell phoneLabelCell = initPdfCell(phoneLabel);
        setLRPadding(phoneLabelCell);
        table.addCell(phoneLabelCell);

        Paragraph phoneContent = str2ParaByTwoFont(projectApply.getPhone(), 9f, BaseColor.BLACK);
        phoneContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell phoneContentCell = initPdfCell(phoneContent);
        setLRPadding(phoneContentCell);
        table.addCell(phoneContentCell);

        Paragraph emailLabel = str2ParaByTwoFont("电子邮箱", 9f, BaseColor.BLACK);
        emailLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell emailLabelCell = initPdfCell(emailLabel);
        setLRPadding(emailLabelCell);
        table.addCell(emailLabelCell);

        Paragraph emailContent = str2ParaByTwoFont(projectApply.getEmail(), 9f, BaseColor.BLACK);
        emailContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell emailContentCell = initPdfCell(emailContent);
        setLRPadding(emailContentCell);
        table.addCell(emailContentCell);

        Paragraph addressLabel = str2ParaByTwoFont("通讯地址", 9f, BaseColor.BLACK);
        addressLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell addressLabelCell = initPdfCell(addressLabel);
        setLRPadding(addressLabelCell);
        table.addCell(addressLabelCell);

        Paragraph addressContent = str2ParaByTwoFont(projectApply.getAddress(), 9f, BaseColor.BLACK);
        addressContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell addressContentCell = initPdfCell(addressContent);
        addressContentCell.setColspan(3);
        addressContentCell.setRowspan(1);
        setLRPadding(addressContentCell);
        table.addCell(addressContentCell);

        Paragraph companyLabel = str2ParaByTwoFont("工作单位", 9f, BaseColor.BLACK);
        companyLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell companyLabelCell = initPdfCell(companyLabel);
        setLRPadding(companyLabelCell);
        table.addCell(companyLabelCell);

        Paragraph companyContent = str2ParaByTwoFont(projectApply.getCompany(), 9f, BaseColor.BLACK);
        companyContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell companyContentCell = initPdfCell(companyContent);
        companyContentCell.setColspan(3);
        companyContentCell.setRowspan(1);
        setLRPadding(companyContentCell);
        table.addCell(companyContentCell);

        Paragraph researchFieldLabel = str2ParaByTwoFont("研究领域", 9f, BaseColor.BLACK);
        researchFieldLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell researchFieldLabelCell = initPdfCell(researchFieldLabel);
        setLRPadding(researchFieldLabelCell);
        table.addCell(researchFieldLabelCell);

        Paragraph researchFieldContent = str2ParaByTwoFont(projectApply.getResearchField(), 9f, BaseColor.BLACK);
        researchFieldContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell researchFieldContentCell = initPdfCell(researchFieldContent);
        researchFieldContentCell.setColspan(3);
        researchFieldContentCell.setRowspan(1);
        setLRPadding(researchFieldContentCell);
        table.addCell(researchFieldContentCell);

        Paragraph researchDirectionLabel = str2ParaByTwoFont("研究方向", 9f, BaseColor.BLACK);
        researchDirectionLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell researchDirectionLabelCell = initPdfCell(researchDirectionLabel);
        researchDirectionLabelCell.setColspan(2);
        researchDirectionLabelCell.setRowspan(1);
        setLRPadding(researchDirectionLabelCell);
        table.addCell(researchDirectionLabelCell);

        Paragraph researchDirectionContent = str2ParaByTwoFont(projectApply.getResearchDirection(), 9f, BaseColor.BLACK);
        researchDirectionContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell researchDirectionContentCell = initPdfCell(researchDirectionContent);
        researchDirectionContentCell.setColspan(3);
        researchDirectionContentCell.setRowspan(1);
        setLRPadding(researchDirectionContentCell);
        table.addCell(researchDirectionContentCell);

        Paragraph projectNameLabel = str2ParaByTwoFont("项目名称", 9f, BaseColor.BLACK);
        projectNameLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell projectNameLabelCell = initPdfCell(projectNameLabel);
        projectNameLabelCell.setColspan(2);
        projectNameLabelCell.setRowspan(1);
        setLRPadding(projectNameLabelCell);
        table.addCell(projectNameLabelCell);

        Paragraph projectNameContent = str2ParaByTwoFont(projectApply.getProjectName(), 9f, BaseColor.BLACK);
        projectNameContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell projectNameContentCell = initPdfCell(projectNameContent);
        projectNameContentCell.setColspan(3);
        projectNameContentCell.setRowspan(1);
        setLRPadding(projectNameContentCell);
        table.addCell(projectNameContentCell);

        Paragraph zhKeyWordLabel = str2ParaByTwoFont("中文关键字", 9f, BaseColor.BLACK);
        zhKeyWordLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell zhKeyWordLabelCell = initPdfCell(zhKeyWordLabel);
        zhKeyWordLabelCell.setColspan(2);
        zhKeyWordLabelCell.setRowspan(1);
        setLRPadding(zhKeyWordLabelCell);
        table.addCell(zhKeyWordLabelCell);

        Paragraph zhKeyWordContent = str2ParaByTwoFont(projectApply.getZhKeyword(), 9f, BaseColor.BLACK);
        zhKeyWordContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell zhKeyWordContentCell = initPdfCell(zhKeyWordContent);
        zhKeyWordContentCell.setColspan(3);
        zhKeyWordContentCell.setRowspan(1);
        setLRPadding(zhKeyWordContentCell);
        table.addCell(zhKeyWordContentCell);

        Paragraph enKeyWordLabel = str2ParaByTwoFont("英文关键字", 9f, BaseColor.BLACK);
        enKeyWordLabel.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
        PdfPCell enKeyWordLabelCell = initPdfCell(enKeyWordLabel);
        enKeyWordLabelCell.setColspan(2);
        enKeyWordLabelCell.setRowspan(1);
        setLRPadding(enKeyWordLabelCell);
        table.addCell(enKeyWordLabelCell);

        Paragraph enKeyWordContent = str2ParaByTwoFont(projectApply.getEnKeyword(), 9f, BaseColor.BLACK);
        enKeyWordContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell enKeyWordContentCell = initPdfCell(enKeyWordContent);
        enKeyWordContentCell.setColspan(3);
        enKeyWordContentCell.setRowspan(1);
        setLRPadding(enKeyWordContentCell);
        table.addCell(enKeyWordContentCell);

        Paragraph researchPlanLabel = str2ParaByTwoFont("研究方案", 9f, BaseColor.BLACK);
        enKeyWordLabel.setAlignment(Element.ALIGN_CENTER);
        PdfPCell researchPlanLabelCell = initPdfCell(researchPlanLabel);
        table.addCell(researchPlanLabelCell);

        Paragraph researchPlanContent = str2ParaByTwoFont(projectApply.getResearchPlan(), 9f, BaseColor.BLACK);
        researchPlanContent.setAlignment(Element.ALIGN_LEFT);
        PdfPCell researchPlanContentCell = initPdfCell(researchPlanContent);
        researchPlanContentCell.setColspan(4);
        researchPlanContentCell.setRowspan(1);
        setLRPadding(researchPlanContentCell);
        table.addCell(researchPlanContentCell);

        Paragraph researchPlanLabel1 = str2ParaByTwoFont("申报人简历", 9f, BaseColor.BLACK);
        researchPlanLabel1.setAlignment(Element.ALIGN_CENTER);
        PdfPCell researchPlanLabelCell1 = initPdfCell(researchPlanLabel1);
        researchPlanLabelCell1.setColspan(1);
        researchPlanLabelCell1.setRowspan(1);
        table.addCell(researchPlanLabelCell1);

        Paragraph researchPlanContent1 = str2ParaByTwoFont(projectApply.getResume(), 9f, BaseColor.BLACK);
        researchPlanContent1.setAlignment(Element.ALIGN_LEFT);
        PdfPCell researchPlanContentCell1 = initPdfCell(researchPlanContent1);
        researchPlanContentCell1.setColspan(4);
        researchPlanContentCell1.setRowspan(1);
        setLRPadding(researchPlanContentCell1);
        table.addCell(researchPlanContentCell1);

        Paragraph researchPlanLabel2 = str2ParaByTwoFont("代表性论著", 9f, BaseColor.BLACK);
        researchPlanLabel2.setAlignment(Element.ALIGN_CENTER);
        PdfPCell researchPlanLabelCell2 = initPdfCell(researchPlanLabel2);
        table.addCell(researchPlanLabelCell2);

        Paragraph researchPlanContent2 = str2ParaByTwoFont(projectApply.getMagnumOpus(), 9f, BaseColor.BLACK);
        researchPlanContent2.setAlignment(Element.ALIGN_LEFT);
        PdfPCell researchPlanContentCell2 = initPdfCell(researchPlanContent2);
        researchPlanContentCell2.setColspan(4);
        researchPlanContentCell2.setRowspan(1);
        setLRPadding(researchPlanContentCell2);
        table.addCell(researchPlanContentCell2);

        return table;
    }

    private static void setLRPadding(PdfPCell nameContentCell) {
        nameContentCell.setPaddingLeft(10f);
        nameContentCell.setPaddingRight(10f);
    }

    private static PdfPCell initPdfCell(Paragraph pp) {
        PdfPCell cell = new PdfPCell();
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setPaddingTop(-2f);//把字垂直居中
        cell.setPaddingBottom(8f);//把字垂直居中
        cell.addElement(pp);
        return cell;
    }

    private static PdfPCell getTitleCell() {
        Font font = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 20f, Font.BOLD, BaseColor.BLACK);
        PdfPCell titleCell = new PdfPCell();
        Paragraph paragraphTitle = new Paragraph("鸿之微横向项目申请表");
        paragraphTitle.setAlignment(Element.ALIGN_CENTER);
        paragraphTitle.setSpacingBefore(30f);
        paragraphTitle.setFont(font);
        titleCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        titleCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);//然并卵
        titleCell.setPaddingTop(-2f);//把字垂直居中
        titleCell.setPaddingBottom(18f);//把字垂直居中
        titleCell.addElement(paragraphTitle);
        titleCell.setBorder(0);
        return titleCell;
    }

    private static PdfPCell getNoCell(String applyNo) throws DocumentException {
        Font font = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, 20f, Font.BOLD, BaseColor.BLACK);
        PdfPCell noCell = new PdfPCell();
        Paragraph paragraphNo = new Paragraph("申请编号：" + applyNo);
        paragraphNo.setAlignment(Element.ALIGN_LEFT);
        paragraphNo.setSpacingBefore(20f);
        font.setSize(9f);
        paragraphNo.setFont(font);
        noCell.setHorizontalAlignment(PdfPCell.LEFT);
        noCell.setVerticalAlignment(PdfPCell.LEFT);
        noCell.setPaddingTop(-2f);//把字垂直居中
        noCell.setPaddingBottom(8f);//把字垂直居中
        noCell.addElement(paragraphNo);
        noCell.setBorder(0);
        return noCell;
    }

    /**
     * 两种字体显示文字
     *
     * @param content
     * @param size
     * @param color
     * @return
     */
    private static Paragraph str2ParaByTwoFont(String content, float size, BaseColor color) {
        Paragraph res = new Paragraph();
        res.setAlignment(1);
        FontSelector selector = getFontSelector(size, color, Font.UNDEFINED);
//        FontSelector selectorBOLD = getFontSelector(size, color, Font.BOLD);
        res.add(selector.process(content));
//        List<ContentWrapper> contentWrappers = new ArrayList<>();
//        htmlToContent(contentWrappers, content, "");
//        contentWrappers.forEach(contentWrapper -> {
//            Phrase ph;
//            if(StrUtil.isNotBlank(contentWrapper.getStyle()) && contentWrapper.getStyle().contains("<strong")) {
//                ph = selectorBOLD.process(contentWrapper.getContent());
//            } else {
//                ph = selector.process(contentWrapper.getContent());
//            }
//            res.add(ph);
//        });
        return res;
    }

    @Data
    @AllArgsConstructor
    static class ContentWrapper {
        String style;
        String content;
    }

    private  static void htmlToContent(List<ContentWrapper> contents, String content, String tag) {
        if(StrUtil.isBlank(content)) {
            return;
        }
        int beginIndex = content.indexOf("<");
        int endIndex = content.indexOf(">") + 1;
        if(beginIndex == -1) {
            contents.add(new ContentWrapper(tag, content));
            return;
        }
        if(beginIndex == 0) {
            return;
        }
        contents.add(new ContentWrapper(tag, content.substring(0, beginIndex)));
        tag = content.substring(beginIndex, endIndex);
        content = content.substring(endIndex);
        htmlToContent(contents, content, tag);
    }

    private static FontSelector getFontSelector(float size, BaseColor color, int style) {
        FontSelector selector = new FontSelector();
        //非汉字字体颜色
        Font f1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, size, style);
        f1.setColor(color);
        //汉字字体颜色
        Font f2 = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, size, style);
        f2.setColor(color);

        selector.addFont(f1);
        selector.addFont(f2);
        return selector;
    }

//    @SneakyThrows
//    public static void main(String[] args) {
//        // 获取logo
//        byte[] logBytes = HttpUtil.downloadBytes("https://prod-saas-base.s3.cn-northwest-1.amazonaws.com.cn/project/logo.png");
//        // 获取水印
//        byte[] remarkBytes = HttpUtil.downloadBytes("https://prod-saas-base.s3.cn-northwest-1.amazonaws.com.cn/project/remark.png");
//
//        ProjectApply projectApply = Json.parseObject("{\"pid\":\"1427936935078400000\",\"creatorId\":\"1343747573836857344\",\"editorId\":\"1343747573836857344\",\"createTime\":\"2021-08-18T10:14:30.000+00:00\"," +
//                "\"updateTime\":\"2021-08-18T10:21:15.000+00:00\"," +
//                "\"isDelete\":0,\"flowInstanceId\":\"1427936935028068351\",\"userId\":\"1343747573836857344\",\"userName\":\"hzwhj\",\"realName\":\"累累\",\"phone\":\"15557125616\",\"email\":\"277621355@163.com\"," +
//                "\"address\":\"供一份中期进展报告，\"," +
//                "\"company\":\"供一份中期进展报告，\",\"researchDirection\":\"式 咨询热线：021-50550302（时\",\"researchField\":\"供一份中期进展报告，\",\"projectName\":\"供一份中期进展报告，\",\"zhKeyword\":\"供一份中期进展报告，\",\"enKeyword\":\"FF\"," +
//                "\"researchPlan\":\"“爱科研，用鸿之微云”项目申报指南\\n\\n鸿之微科技（上海）股份有限公司（简称:鸿之微）是国内专注于从事多尺度仿真技术研发的高新企业，主要为高校、科研院所、工业企业提供专业的材料设计和工艺仿真软件，以及高水平定制化计算解决方案，帮助客户提升研发效率、优化工艺。\\n为引领多尺度材料仿真技术，成为加速材料研发与创新的首选合作伙伴，鸿之微于2021年4月15" +
//                "日推出“鸿之微云”。鸿之微云集成了软件云、工具云、数据云，并配套相应的周边服务，专门为科研工作者提供一站式、一体化的科学计算服务。软件云中包含了鸿之微自主知识产权的多尺度材料仿真软件；工具云包含了丰富的协同科研办公应用工具；数据云包含了大量的材料仿真数据用于筛选学习。\\n" +
//                "与此同时，为了更好的促进鸿之微云健康发展，让鸿之微云产品更多的应用于科学研究工作中，以应用促发展，建立互惠共赢的鸿之微云科研生态。特面向鸿之微云用户发布项目申报指南，广泛征集鸿之微自主知识产权多尺度材料仿真软件应用与测试案例。\\n\\n一、征集软件测试与应用范围\\n软件1：Device " +
//                "Studio材料建模与仿真平台软件。\\n软件2：Nanodcal第一性量子输运计算软件。\\n软件3：DS-PAW第一性平面波计算软件。\\n软件4：RESCU第一性大体系计算软件。\\n软件5：Nanoskim紧束缚模型科学计算软件。\\n软件6：FIRST材料快速虚拟筛选软件。\\n软件7：MOMAP分子材料发光与输运性质计算软件。\\n软件8：STEMS微观组织演化相场计算软件。\\n软件9：TOPS" +
//                "聚合物高分子相结构计算软件。\\n" +
//                "软件介绍请见附件材料（一）\\n\\n二、项目申报要求\\n鸿之微云年版会员用户。\\n三、项目执行期限\\n鸿之微云年版会员有效期内。\\n四、项目资助额度与方式\\n项目经费额度3万。\\n鸿之微云会员（9" +
//                ".8万/年版）：分两次支付，立项后发放35%经费；鸿之微云有效期内，项目通过验收后支付剩余65%经费。\\n鸿之微云会员（其他年版）：鸿之微云有效期内，项目通过验收后一次性支付全额经费。\\n五、项目申报方式\\n项目申报采用网上申报方式，无需送交纸质材料。申请人通过鸿之微云主页“https://iresearch.net.cn/home” -- " +
//                "进入“项目申报“页面，填写申报材料。亦可通过点击此链接，直接进入申报页面。\\n六、项目验收标准\\n主要包括项目执行期间、鸿之微云账户有效期内的一些指标要求，可以根据会员用户的实际情况进行协商确定。指标包括但不限于：\\n1)项目执行有效期为1年；\\n2)发表SCI论文，论文第一次投稿时间必须在项目有效期内；\\n3)发表的SCI论文至少正确引用一款上述所列鸿之微软件；\\n4)" +
//                "发表的SCI论文致谢至少包含其中一条：\\n\uF06C由鸿之微提供计算机时支持；\\n\uF06C由鸿之微PROP计划支持；\\n\uF06C由鸿之微提供技术交流支持；\\n\uF06C文章作者包含鸿之微应用工程师。\\n5)提供结题报告（包括计算结果和数据）；\\n6)提供一份中期进展报告，中期进展报告时间双方协商；\\n7)" +
//                "鸿之微项目合同指定的其他验收标准。\\n\\n七、评审方式\\n鸿之微项目委员会成员组联合评审。\\n八、立项公示\\n鸿之微项目委员会挑选优秀课题，定期于鸿之微云官网公示，并签订项目合作合同。\\n九、其他说明\\n1)鸿之微云账户生效日期不能晚于项目申请日期。\\n2)项目的审核批准周期控制在10个工作日内。\\n3)" +
//                "所有项目统一编号规则，以鸿之微盖章寄出为准。\\n\\n十、联系方式\\n咨询热线：021-50550302（时间：工作日9:00 - 17:00）\\n联系邮箱：Project@hzwtech.com\\n联系人：鸿之微研发经理 龚奎\\n公司地址：上海市浦东新区新金桥路1599号C2栋6层\",\"resume\":\"供一份中期进展报告，\",\"magnumOpus\":\"供一份中期进展报告，\"}\n",
//            ProjectApply.class);
//
//        PdfUtils.createProjectApplyPDF(new FileOutputStream("/Users/sonam/1.pdf"),
//            new ByteArrayInputStream(logBytes), null,
////            new ByteArrayInputStream(remarkBytes),
//            "鸿之微横向项目申请表",
//            projectApply);
//    }
}
